//
//  AlertViewTool.m
//  AlumniBook
//
//  Created by 喂！ on 2018/10/29.
//  Copyright © 2018年 well. All rights reserved.
//

#import "AlertViewTool.h"

@implementation AlertViewTool


-(void)showWith:(NSString*)titleStr
{
    
    UIView *tipView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 490 * SCREEN_SCALE, 90 * SCREEN_SCALE)];
    tipView.backgroundColor = [UIColor whiteColor];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10 * SCREEN_SCALE, 25 * SCREEN_SCALE, 40 * SCREEN_SCALE, 40 * SCREEN_SCALE)];
    [imageView setImage:[UIImage imageNamed:@"Error_Icon"]];
    [tipView addSubview:imageView];
    UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * SCREEN_SCALE, 0, 430 * SCREEN_SCALE, 80 * SCREEN_SCALE)];
    tipLabel.numberOfLines = 0;
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.text = titleStr;
    [tipView addSubview:tipLabel];
    
    
    // Here we need to pass a full frame
    CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
    
    // Add some custom content to the alert view
    [alertView setContainerView:tipView];
    
    // Modify the parameters
//    [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"Close1", @"Close2", @"Close3", nil]];
//    [alertView setDelegate:self];
    
    // You may use a Block, rather than a delegate.
    [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
        NSLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
        [alertView close];
    }];
    
    [alertView setUseMotionEffects:true];
    [alertView setCloseOnTouchUpOutside:YES];
    
    // And launch the dialog
    [alertView show];
    
    alertView.layer.shouldRasterize = NO;
}


@end
